package com.frank.ELK;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.nio.file.Files;
import java.nio.file.Paths;

/**
 * @author 小石潭记
 * @date 2020/10/30 11:03
 * @Description: ${todo}   https://blog.csdn.net/weixin_41358004/article/details/106206200
 */
@RestController
@RequestMapping("/elk")
@Slf4j
public class ELKController {

    @Value("${updateNumber}")
    private int updateNumber;

    @GetMapping("/index")
    public void index() throws Exception{
        log.info("测试的elk的info日志收集,{}", updateNumber);
        log.error("测试的elk的错误日志收集");
        log.debug("测试的elk的debug日志收集");

        // todo 这样读取出来的路径前面多了个/ 需要注意
        /*String file = this.getClass().getResource("/script/Main.txt").getFile();
        // /D:/IdeaCode/newcode/springboot-learn/target/classes/script/Main.txt
        log.info("file,{}", file);
        // D:/IdeaCode/newcode/springboot-learn/target/classes/script/Main.txt
        String substring = file.substring(1);
        log.info("substring,{}", substring);
        String s1 = new String(Files.readAllBytes(Paths.get(substring)));

        log.info("读取的文件,{}", s1);*/
    }

}
